import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/component/component.dart';
import 'package:leader_help/utils/util.dart';

import 'index.dart';
import 'widgets/widgets.dart';

class MakePlanPage extends GetView<MakePlanController> {
  const MakePlanPage({Key? key}) : super(key: key);

  // 内容页
  Widget _buildView() {
    return ListView.separated(
        itemBuilder: (ctx, index) {
          var _mod = controller.state.list![index];
          return PlanCell(
            mod: _mod,
            cellTap: controller.actionCell,
            chooseTap: controller.actionCellChoose,
          );
        },
        separatorBuilder: (ctx, index) {
          return SizedBox(
            height: 20.h,
          );
        },
        itemCount: controller.state.list?.length ?? 0);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MakePlanController>(
      builder: (_) {
        return Scaffold(
          appBar: detailAppBar(
            context,
            title: '定方案',
            bottom: PreferredSize(
              child: PageSubtitleText(
                title: '请为问题选定目标和方案，选中后进行确认即可。',
                height: 50.r,
              ),
              preferredSize: Size.fromHeight(50.r),
            ),
          ),
          body: Container(
            margin: EdgeInsets.only(bottom: 50.r + SizeFit.safeBottom),
            child: _buildView(),
          ),
          bottomSheet: GestureDetector(
            onTap: controller.actionPlan,
            child: Container(
              margin: EdgeInsets.only(bottom: SizeFit.safeBottom),
              color: ColorsUtil.red,
              width: Get.width,
              height: 50.r,
              alignment: Alignment.center,
              child: Text(
                '选定方案并做安排',
                style: pfMediumStyle(color: Colors.white, fontSize: 15.sp),
              ),
            ),
          ),
        );
      },
    );
  }
}
